
/*
 * MoonCake v1.3.1 - Form Cloning Demo JS
 *
 * This file is part of MoonCake, an Admin template build for sale at ThemeForest.
 * For questions, suggestions or support request, please mail me at maimairel@yahoo.com
 *
 * Development Started:
 * July 28, 2012
 * Last Update:
 * December 07, 2012
 *
 */

;(function( j5, window, document, undefined ) {
			
	j5(document).ready(function() {
		if( j5.fn.sheepIt ) {

			/*j5('#input_cloning').sheepIt({
				separator: '', 
				maxFormsCount: 5
			});
			j5('#oinput_cloning').sheepIt({
				separator: '', 
				iniFormsCount: 0, 
				minFormsCount: 0, 
				maxFormsCount: 5
			});*/
			j5('#event_cloning').sheepIt({
				separator: '', 				
				data: [
					{ ename: 'Sự Kiện 01', estart: '05/01/2013', eend: '06/01/2013' }, 
					{ ename: 'Sự Kiện 02', estart: '11/10/2013', eend: '11/12/2013' }
				], 				
				afterAdd: function(source, newform) {
					if( j5.fn.datepicker ) {
						var from = j5(newform).find('.datepicker_s'), 
							to = j5(newform).find('.datepicker_e');

						//from.datepicker({ dateFormat: 'dd-mm-yy' });
						from.datepicker({
							dateFormat: 'dd/mm/yy',
							//defaultDate: "+1w",
							numberOfMonths: 1, 
							showOtherMonths: true, 
							onSelect: function( selectedDate ) {
								to.datepicker( "option", "minDate", selectedDate );
							}
						});
						//to.datepicker({ dateFormat: 'dd-mm-yy' });
						to.datepicker({
							dateFormat: 'dd/mm/yy',
							//defaultDate: "+1w",
							numberOfMonths: 1, 
							showOtherMonths: true, 
							onSelect: function( selectedDate ) {
								from.datepicker( "option", "maxDate", selectedDate );
							}
						});

					}
				}
			});
		}
	});
	
	
}) (jQuery, window, document);